﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BanVeXemPhim_Presentation
{
    public partial class FormNhapThongTinKhachHang : Form
    {
        public FormNhapThongTinKhachHang()
        {
            InitializeComponent();
        }

        private FormMHBanVe _formParent;

        public FormMHBanVe FormParent
        {
            get { return _formParent; }
            set { 
                _formParent = value; 
                if(_formParent!=null)
                {
                    EventLayThongTinKhachHang+=new ThongTinKhachHang(_formParent.XuLyThongTinKhachHang);
                }
            }
        }

        public delegate void ThongTinKhachHang(bool result,KhachHangDTO khachHangDto);
        public event ThongTinKhachHang EventLayThongTinKhachHang;

        private void buttonOk_Click(object sender, EventArgs e)
        {
            if(this.textBoxHoten.Text=="" || this.textBoxCmnd.Text=="" || this.textBoxDiaChi.Text=="")
            {
                MessageBox.Show("Bạn nhấp thiếu thông tin !!!");
                return;
            }
            KhachHangDTO khachHangDto = new KhachHangDTO();
            khachHangDto.HoTen = this.textBoxHoten.Text;
            khachHangDto.CMND = this.textBoxCmnd.Text;
            khachHangDto.DiaChi = this.textBoxCmnd.Text;

            if(EventLayThongTinKhachHang!=null)
            {
                Hide();
                EventLayThongTinKhachHang(true,khachHangDto);
            }
            Dispose();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            if(EventLayThongTinKhachHang!=null)
            {
                EventLayThongTinKhachHang(false, null);
            }
            Dispose();
        }
    }
}
